package class202204._26_30._27;

import java.util.Arrays;
import java.util.Scanner;

class Test {
    public static void hello() {
        System.out.println("hello");
    }
}

public class demo20220427 {
    public static void main1(String[] args) {
        int n = 1;
        int sum = 0;
        while (n<6){
            int m = 1;
            int tmp = 1;
            while (tmp<=n){
                m *=tmp;
                tmp++;
            }
            sum +=m;
            n++;
        }
        System.out.println(sum);
    }

    public static void main2(String[] args) {
        int num = 100;
        while (num<201){
            if (num%3==0){
                System.out.println("100-200间第一个三位数是："+num);
                break;
            }
            num++;
        }
    }
//一球从h米高度自由落下，每次落地后反弹回原高度的一半再落下，求它在第n次落地时共经过了多少米？第n次反弹多高？
//输入描述：
//输入小球的初始高度和落地的次数（先输入小球初始高度再输入反弹次数）
//输出描述：
//输出小球反弹的高度和经过的距离（先输出反弹的高度再输出经过的距离，中间用空格隔开）
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        float h = scanner.nextFloat();
        int n = scanner.nextInt();
        float sum = h;
        int i = 1;
        while (i <= n) {
            h /= 2;
            sum += (float) 2*h;
            i++;
        }
        sum-=2*h;//上面多加了2h

        //write your code here......
        System.out.println(String.format("%.3f", h) + " " + String.format("%.3f", sum));
    }
//键盘输入任意多个10000以内正整数（负数代表结束），求出它们的平均数，
    public static void main4(String[] args) {
            Scanner scan = new Scanner(System.in);
            int sum = 0;
            int num = 0;
            while(scan.hasNextInt()){
                int tem = scan.nextInt();
                if(tem<0){
                    break;
                }
                sum+=tem;
                num++;
            }
            double avg = (double)sum/num;
            System.out.println(String.format("%.2f",avg));
            scan.close();
    }
    //找出非空数组内只出现一次的元素
    public static int func(int[] array){
        int ret = 0;
        for (int i = 0; i < array.length; i++) {
            ret ^=array[i];
        }
        return ret;
    }

    public static void main5(String[] args) {
        int[] array ={4,3,3,6,5,6,5};
        int ret = func(array);
        System.out.println(ret);
    }
    public static void main6(String[] args) {
        // TODO Auto-generated method stub
        Test test=null;
        Test.hello();
    }

}
